﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EFCore.Core.Models
{
    public class BaseResponse<T>
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int Code { get; set; } = ResultCode.NormalCode;

        /// <summary>
        /// 返回信息
        /// </summary>
        public string Message { get; set; } = "";

        /// <summary>
        /// 若返回的数据为单个集合（前端需要告知行数，则返回行数，否则默认为0）/如果是更新类操作可用于存储受影响行数
        /// </summary>
        public long Count { get; set; } = 0;

        /// <summary>
        /// 返回数据 / 更新类操作可存储上次操作的ID  SELECT @@Identity
        /// </summary>
        public T Data { get; set; } = default(T);

        /// <summary>
        /// 判断是否成功
        /// </summary>
        /// <returns></returns>
        public bool IsSucceed()
        {
            return this.Code == ResultCode.NormalCode;
        }
    }
}
